#include "NiMilesAudioPCH.h"

#include "NiAudioListener.h"
#include "NiAudioSystem.h"
#include <NiMatrix3.h>

NiImplementRTTI(NiAudioListener, NiAVObject);

NiAudioListener::NiAudioListener()
{
	m_kDirection = NiPoint3(1, 0, 0);
	m_kUp = NiPoint3(0, 1, 0);
	
	m_kLocal.m_Translate = NiPoint3(0, 0, 0);
	
	NiMatrix3 diagMatrix;
	diagMatrix.MakeDiagonal(1.0, 1.0, 1.0);
	m_kLocal.m_Rotate = diagMatrix;
	m_kLocalVelocity = NiPoint3(0, 0, 0);
	
	m_pvListener = 0;
}

NiAudioListener::~NiAudioListener()
{
	Release();
}

void NiAudioListener::Release()
{
}

void NiAudioListener::UpdateDownwardPass(NiUpdateProcess& kUpdate)
{
	NiAVObject::UpdateDownwardPass(kUpdate);
	UpdateAudioData();
}

void NiAudioListener::UpdateSelectedDownwardPass(NiUpdateProcess& kUpdate)
{
	NiAVObject::UpdateSelectedDownwardPass(kUpdate);
	UpdateAudioData();
}

void NiAudioListener::UpdateRigidDownwardPass(NiUpdateProcess& kUpdate)
{
	NiAVObject::UpdateRigidDownwardPass(kUpdate);
	UpdateAudioData();
}

NiObject* NiAudioListener::CreateObject(const char**,
	unsigned int)
{
	return NiAudioSystem::GetAudioSystem()->GetListener();
}

void NiAudioListener::LoadBinary(NiStream& stream)
{
	NiAVObject::LoadBinary(stream);
	
	m_kDirection.LoadBinary(steam);
	m_kUp.LoadBinary(stream);
}


